package demo;

import java.sql.Time;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

import static demo.Demo.calculate;
import static demo.Demo.updateEdge;


public class Main extends Demo{
    static Scanner scanner = new Scanner(System.in);
    static HashMap<String,String> hashMap = new HashMap<>();


    public static void main(String[] args) {
        Main m = new Main();
        m.insertViewInformation();
        while (true){
            int x = begin();
            switch (x){
                case 1:
                    showViewInformation();
                    break;
                case 2:
                    calculate();
                    break;
                case 3:
                    updateEdges();
                    break;
                case 4:
                    updateViewInformation();
                    break;
            }

        }
    }
    public static void display(int[][] enter){
        System.out.println("各景点之间最短路径长度：");
        for(int i=0;i< enter.length;i++){
            for (int j=0;j< enter.length;j++)
                System.out.println(enter[i][j]+"\t");
            System.out.println();
        }
    }

    public static int begin(){
        System.out.println("   **欢迎使用景区导览电子地图**");
        System.out.println("【老虎洞】"+"———【狮子园】" + "——【入口】"+"——【天鹅湖】"+"——【鸟林】" );
        System.out.println("    |"+"        |"+"        "+"             |"+"       |");
        System.out.println("    |"+"______【猴山】"+"       "+"     【熊猫基地】" +"____|");
        System.out.println("1.查询景点相关信息");
        System.out.println("2.查询两景点间的最短距离");
        System.out.println("3.修改两景点间的道路信息");
        System.out.println("4.更新景点信息");
        return scanner.nextInt();
    }

    public static void updateEdges(){
        int start = 0, end = 0;
        System.out.println("请输入需要修改的两景点名称：");
        Scanner scanner = new Scanner(System.in);
        String string = scanner.nextLine();
        String[] strings = string.split(" ");
        String s = strings[0];
        String e= strings[1];
        String[] enter = {"入口","狮子园","猴山","老虎洞","鸟林","天鹅湖","熊猫基地"};
        for(int i = 0; i < enter.length; i++){
            if(s.equals(enter[i])){
                start = i;
            }
            if(e.equals(enter[i])){
                end = i;
            }
        }
        System.out.println("请输入需要修改的道路信息：");
        int weight = scanner.nextInt();
        updateEdge(start,end,weight);
    }

    public static void showViewInformation(){
        System.out.println("请输入需要查询的景点名称：");
        String name = scanner.next();

        System.out.println(hashMap.get(name));
    }

    public void insertViewInformation(){
        hashMap.put("入口","欢迎进入动物园，祝你旅途愉快");
        hashMap.put("狮子园","内有举国闻名的大狮子，请勿喂食投食");
        hashMap.put("猴山","品种众多，及其具有灵性，请勿靠近，以免受伤");
        hashMap.put("老虎洞","东北虎，极其稀有");
        hashMap.put("鸟林","林中有丰富的鸟类，请勿伤害");
        hashMap.put("天鹅湖","水上婀娜多姿的天鹅，使你心情更加愉悦");
        hashMap.put("熊猫基地","中国代表动物，及其珍惜");

    }

    public static void updateViewInformation(){
        System.out.println("请输入需要更新的景点名称：");
        String name = scanner.next();
        System.out.println("请输入需要更新的信息：");
//        scanner.next();
//        System.out.println(name);
        String information = scanner.next();
//        System.out.println(information);
        hashMap.replace(name,information);
        System.out.println("更新成功");
    }
}
